/*
 * Copyright (C) 拾光分享网 
 * All rights reserved, Designed By www.hiai.top.
 * Email：goodsking@163.com.
 * Version：V1.0.2(20230701).
 */
package top.hiai._admin.comments;

import com.jfinal.plugin.activerecord.Page;

import top.hiai.common.model.Comments;
import top.hiai.config.BaseController;

/**
* @Author www.hiai.top
* @Email  goodsking@163.com
* @Message 更多资源尽在www.hiai.top
* @Introduction 类的介绍   文章分类话题管理
*/

public class CommentsAdminController extends BaseController{

	CommentsAdminService srv = CommentsAdminService.me;
	/**
	 * 获取所有的文章分类
	 */
	public void index() {
		Page<Comments> commentsPage = srv.paginate(getParaToInt("p", 1),limtCount);
		setAttr("commentsPage", commentsPage);
		render("commentsList.html");
	}
	/**
	 * 根据分类ID查找
	 */
	public void findById(){
		Comments comments = srv.findById(getParaToInt("tid"));
		renderJson("result",comments);
	}
	/**
	 * 添加分类
	 */
	public void commentsAdd(){
		Boolean result = srv.commentsAdd(get("name"),getInt("sort"),get("remarks"));
		renderJson("success",result);
	}
	
	/**
	 * 修改分类
	 */
	public void commentsEdit(){
		Boolean result = srv.commentsEdit(getInt("tid"),get("name"),getInt("sort"),get("remarks"));
		renderJson("success",result);
	}

	public void commentsDelete(){
		srv.commentsDelete(getInt("tid"));
		redirect("/admin/comments");
	}
}